<div id="main-nav">
    <ul class="ul-level-1">
        <?php
        foreach ($this->theloai1 as $tl1) {
            ?>
            <li class="menu-sach">   
                <a href="#"><?php echo $tl1['tentl1'] ?></a>
                <div class="menu-columns menu-columns-1">
                    <div class="menu-column" >
                        <ul class="ul-level-3">
                            <?php
                            foreach ($this->theloai2 as $tl2) {
                                for ($i = 0; $i < count($tl2); $i++) {
                                    if ($tl2[$i]['matl1'] == $tl1['matl1']) {
                                        
                                        if ($i == 0) {
                                            ?>
                                            <li class="first-item">
                                                <a href="#"><?php echo $tl2[$i]['tentl2'] ?></a>
                                            </li>
                                        <?php } else if ($i == count($tl2) - 1) {
                                            ?>
                                            <li class="last-item">
                                                <a href="#"><?php echo $tl2[$i]['tentl2'] ?></a>
                                            </li>
                                        <?php } else { ?>
                                            <li class="">
                                                <a href="#"><?php echo $tl2[$i]['tentl2'] ?></a>
                                            </li>
                                            <?php
                                        }
                                    }
                                }
                            }
                            ?>
                        </ul>
                    </div>
                    <div class="cleardiv"></div>
                </div>
            </li>
        <?php } ?> 
    </ul>
    <div class = "cs-hotline"><span class = "hotline-text">HOTLINE</span> 1900 6656</div>
</div>